<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" style="display: flex; flex-wrap: nowrap;"
             :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="充值对象" prop="F1006" style="display: flex; flex-wrap: nowrap;">
        <el-select v-model="queryParams.F1006" placeholder="请选择充值对象" clearable style="width: 14vw;" >
          <el-option
            v-for="dict in dict.type.deposit_object"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="充值时间" prop="F1003" style="display: flex; flex-wrap: nowrap;">
        <el-date-picker style="width: 14vw"
                        v-model="queryParams.F1003"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择充值时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item style="margin: 0 0 0 30vw;">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="YYDRechargeHistoryList" @selection-change="handleSelectionChange">
      <el-table-column label="充值公司Id" align="center" prop="f0302" />
      <el-table-column label="充值人" align="center" prop="f0602" >
        <template slot-scope="scope">
          <span v-if="scope.row.f1006 === 1 && scope.row.f0602">{{ scope.row.f0602 }}</span>
          <span v-else>{{scope.row.f0302}}</span>
        </template>
      </el-table-column>
      <el-table-column label="充值金额" align="center" prop="f1002" />
      <el-table-column label="充值方式" align="center" prop="f1004">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.deposit_method" :value="scope.row.f1004"/>
        </template>
      </el-table-column>
      <el-table-column label="充值对象" align="center" prop="f1006">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.deposit_object" :value="scope.row.f1006"/>
        </template>
      </el-table-column>
      <el-table-column label="充值时间" align="center" prop="f1003" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.f1003, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listYYDRechargeHistory} from "@/api/YYDRechargeHistory/YYDRechargeHistory";

export default {
  name: "YYDRechargeHistory",
  dicts: ['deposit_method', 'deposit_object'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 充值记录表格数据
      YYDRechargeHistoryList: [],
      // 账户余额时间范围
      daterangeF1003: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        F1003: null,
        F1006: null,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      if (null != this.daterangeF1003 && '' != this.daterangeF1003) {
        this.queryParams.params["beginF1003"] = this.daterangeF1003[0];
        this.queryParams.params["endF1003"] = this.daterangeF1003[1];
      }
      listYYDRechargeHistory(this.queryParams).then(response => {
        this.YYDRechargeHistoryList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeF1003 = [];
      this.resetForm("queryForm");
      this.handleQuery();
    }
  }
};
</script>
